<template>
	<div class="index">
        <div class="inner_index">
            <div class="index_nav">
                <!-- <router-link class="index_nav_item" tag="div" active-class="active_class" to="/store" replace>
                    <i class="iconfont icon-dianpu"></i><span>我的店铺 </span>
                </router-link> -->
                <!-- <router-link class="index_nav_item" tag="div" active-class="active_class" to="/account" replace>
                    <i class="iconfont icon-zhanghu"></i><span>我的资料 </span>
                </router-link> -->
                <router-link class="index_nav_item" tag="div" active-class="active_class" to="/code" replace>
                    <i class="iconfont icon-ziliao"></i><span>我的邀请码</span>
                </router-link>

                <router-link v-if="isShowCall&&!nowIsPhone" class="index_nav_item" tag="div" active-class="active_class" to="/call" replace>
                    <i class="iconfont icon-ziliao"></i><span>语音呼叫</span>
                </router-link>

                <router-link v-if="isShowCall&&!nowIsPhone" class="index_nav_item" tag="div" active-class="active_class" to="/withDraw" replace>
                    <i class="iconfont icon-ziliao"></i><span>转账记录</span>
                </router-link>
                <router-link v-if="isShowCall&&!nowIsPhone" class="index_nav_item" tag="div" active-class="active_class" to="/lastData" replace>
                    <i class="iconfont icon-ziliao"></i><span>汇总数据</span>
                </router-link>
                <router-link v-if="isShowCall&&!nowIsPhone" class="index_nav_item" tag="div" active-class="active_class" to="/tempGoods" replace>
                    <i class="iconfont icon-ziliao"></i><span>模板商品</span>
                </router-link>
                <router-link v-if="isShowCall&&!nowIsPhone" class="index_nav_item" tag="div" active-class="active_class" to="/gift" replace>
                    <i class="iconfont icon-ziliao"></i><span>礼物管理</span>
                </router-link>
                <router-link v-if="isShowCall&&!nowIsPhone" class="index_nav_item" tag="div" active-class="active_class" to="/clone" replace>
                    <i class="iconfont icon-ziliao"></i><span>店铺修改</span>
                </router-link>

                <router-link v-if="isShowCall&&!nowIsPhone" class="index_nav_item" tag="div" active-class="active_class" to="/team" replace>
                    <i class="iconfont icon-ziliao"></i><span>连锁店铺</span>
                </router-link>
                <router-link v-if="isShowCall&&!nowIsPhone" class="index_nav_item" tag="div" active-class="active_class" to="/storeChangePay" replace>
                    <i class="iconfont icon-ziliao"></i><span>渠道切换</span>
                </router-link>
                <router-link v-if="isShowCall&&!nowIsPhone" class="index_nav_item" tag="div" active-class="active_class" to="/bnsRank" replace>
                    <i class="iconfont icon-ziliao"></i><span>商户排名</span>
                </router-link>
                <router-link v-if="isShowCall" class="index_nav_item" tag="div" active-class="active_class" to="/storeMana/goodsMana" replace>
                    <i class="iconfont icon-ziliao"></i><span>商城管理</span>
                </router-link>
            </div>
            <div class=" router_view_box">
                <div class="router_view">
                    <router-view ></router-view>
                </div>
            </div>
        </div>
	</div>
</template>

<script>
export default {
  	data(){
  		return{
          isShowCall:false,
          nowIsPhone:false
  		}
  	},
    methods:{
       //返回true表示为手机端打开，返回false表示为pc端打开
        isPhone(){
            var userAgentInfo=window.navigator.userAgent;
            var Agents =new Array("Android","iPhone","SymbianOS","Windows Phone","iPad","iPod"); 
            var flag=false; 
            for(var v=0;v<Agents.length;v++) { 
                if(userAgentInfo.indexOf(Agents[v])>0) { 
                flag=true; 
                break; 
                } 
            } 
            return flag; 
        }
    },
    created: function () {

        if ( !localStorage.getItem('token') || !localStorage.getItem('userType') ) {
            this.$router.replace({path:'/login'});
            return;
        }


        this.$http.get("profile").then((res)=>{
            if ( res.data.idCardNo ) {
                if(res.data.mobile == "18482220260"){
                    this.$router.replace({path:'/storeMana/goodsMana'});
                }else{
                    this.$router.replace({path:'/store'});
                }
            } else {
                this.$router.replace({path:'/fillInfo'});  
            }
            if(res.data.mobile=="13980547109" && res.data.name=="姜瑶"){
                sessionStorage.setItem("userData",JSON.stringify(res.data));
                this.isShowCall = true;
            }
            if(res.data.mobile=="18482220260"){
                sessionStorage.setItem("userData",JSON.stringify(res.data));
            }
        }).catch((err)=>{

        })
    },
  	mounted(){
        this.nowIsPhone = this.isPhone();          
  	}
}
</script>
<style lang="scss" scoped>
	@import "index";
</style>
